package org.cy.evolution.ioc.injector;

import org.cy.evolution.ioc.context.EvolutionContext;
import org.cy.evolution.ioc.factory.EvolutionInjector;

public final class EvolutionInjection {

    public static <T> void inject(T instance) {
        String injectClassName = instance.getClass().getCanonicalName();
        EvolutionInjector<T> injector = EvolutionContext.get(EvolutionContext.INJECTOR).get(injectClassName);
        injector.inject(instance);
    }

    public static <T> void destroy(T instance) {
        String injectClassName = instance.getClass().getCanonicalName();
        EvolutionInjector<T> injector = EvolutionContext.get(EvolutionContext.INJECTOR).get(injectClassName);
        injector.destroy();
    }
}
